package com.zillow.channelwriter2.walle;

import com.zillow.channelwriter2.walle.reader.ChannelReader;
import net.dongliu.apk.parser.ApkFile;
import net.dongliu.apk.parser.bean.ApkMeta;

import java.io.File;
import java.io.IOException;

public class PackageUtil {

//    public static void main(String[] args) {
//
////        System.out.println(readApkVersion(new File("C:\\Users\\ByteDance\\Downloads\\channelwriter2\\work\\upload\\apk_inviter_12345678.apk")));
//
////        System.out.println(ChannelReader.get(new File("C:\\Users\\ByteDance\\Downloads\\channelwriter2\\apk_inviter_1637307-1.apk")).getChannel());
//    }


    public static long readApkVersion(File file) {

        try {
            ApkFile apkFile = new ApkFile(file);

            ApkMeta apkMeta = apkFile.getApkMeta();
            apkFile.close();
            return apkMeta.getVersionCode();
        } catch (IOException e) {
            e.printStackTrace();
        }


        return 0L;
    }
}
